package io.kiki.sba.registry.api;

import io.kiki.sba.registry.common.model.store.Url;

import java.net.InetSocketAddress;
import java.util.List;
import java.util.Map;


public interface Server extends Endpoint {

    /**
     * get Server status
     */
    boolean isOpen();

    /**
     * get channels.
     */
    List<Channel> getChannelList();

    /**
     * select one available channel for every ip
     */
    Map<String, Channel> selectAvailableChannelsForHostAddress();
    /**
     * get channel.

     */
    /**
     * select all available channels for every ip
     */
    Map<String, List<Channel>> selectAllAvailableChannelsForHostAddress();

    Channel getChannel(InetSocketAddress remoteAddress);

    /**
     * get channel by url
     */
    Channel getChannel(Url url);

    /**
     * close the channel.
     */
    void close(Channel channel);

    int getChannelCount();

    /**
     * send with callback handler
     */
    void sendCallback(final Channel channel, final Object message, Callback callback, final int timeoutMillis);

    Object sendSync(final Channel channel, final Object message, final int timeoutMillis);
}
